<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8" />
		<title>amis demo</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
		<link rel="stylesheet" href="./tpamis/amis-sdk/sdk.css" />
		<link rel="stylesheet" href="./tpamis/amis-sdk/helper.css" />
		<link rel="stylesheet" href="./tpamis/amis-sdk/iconfont.css" />
		<!-- 这是默认主题所需的，如果是其他主题则不需要 -->
		<!-- 从 1.1.0 开始 sdk.css 将不支持 IE 11，如果要支持 IE11 请引用这个 css，并把前面那个删了 -->
		<!-- <link rel="stylesheet" href="sdk-ie11.css" /> -->
		<!-- 不过 amis 开发团队几乎没测试过 IE 11 下的效果，所以可能有细节功能用不了，如果发现请报 issue -->
		<style>
			html,
			body,
			.app-wrapper {
				position: relative;
				width: 100%;
				height: 100%;
				margin: 0;
				padding: 0;
			}
		</style>
	</head>
	<body>
		<div id="root" class="app-wrapper"></div>
		<script src="./tpamis/amis-sdk/sdk.js"></script>
		<script src="./jquery-3.6.0.min.js"></script>
		<script type="text/javascript">
			//"toolbar": "undo redo | formatselect | bold italic backcolor  | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help"
			function findNode(json, val){
						if (json && json.contentRecord) {
							let cr = json.contentRecord;
							if (cr && cr.contentDocument) {
								let cd = cr.contentDocument;;
								if (cd && cd.contentModuleList) {
									let cml = cd.contentModuleList;
									if (cml && cml.length > 0) {
										for (let i = 0; i < cml.length; i++) {
											let el = cml[i];
											if (el.standardText && el.standardText.body && el.standardText.body
												.textList) {
												if(val){
													el.standardText.body.textList = val;
													return json;
												}
												// jsonVal = el.standardText.body.textList;
												return el.standardText.body.textList;
											}
										}
									}
								}
							}
						}
					}
			let testJson = {
				"warnings": [],
				"contentRecord": {
					"contentReferenceKey": "c1dc68d5-1a2f-4e58-a0eb-8ed8dba30301",
					"contentMetadata": {
						"name": "FXUI1113",
						"marketplaceId": "ATVPDKIKX0DER",
						"status": "DRAFT",
						"badgeSet": [
							"STANDARD"
						],
						"updateTime": "2025-02-12T07:16:55.752Z"
					},
					"contentDocument": {
						"name": "FXUI1113",
						"contentType": "EBC",
						"locale": "en-US",
						"contentModuleList": [{
								"contentModuleType": "STANDARD_COMPANY_LOGO",
								"standardCompanyLogo": {
									"companyLogo": {
										"uploadDestinationId": "aplus-media/sc/ec34cece-012c-47a8-95e3-04a66d9a5e7f.jpg",
										"imageCropSpecification": {
											"size": {
												"width": {
													"value": 600,
													"units": "pixels"
												},
												"height": {
													"value": 180,
													"units": "pixels"
												}
											},
											"offset": {
												"x": {
													"value": 0,
													"units": "pixels"
												},
												"y": {
													"value": 0,
													"units": "pixels"
												}
											}
										},
										"altText": "Vkinman"
									}
								}
							},
							{
								"contentModuleType": "STANDARD_HEADER_IMAGE_TEXT",
								"standardHeaderImageText": {
									"headline": {
										"value": "Motorcycle Amber Bullet Turn Signal",
										"decoratorSet": []
									},
									"block": {
										"image": {
											"uploadDestinationId": "aplus-media/sc/244312f7-176b-4ea0-85a0-eb3c5b042216.jpg",
											"imageCropSpecification": {
												"size": {
													"width": {
														"value": 970,
														"units": "pixels"
													},
													"height": {
														"value": 600,
														"units": "pixels"
													}
												},
												"offset": {
													"x": {
														"value": 0,
														"units": "pixels"
													},
													"y": {
														"value": 0,
														"units": "pixels"
													}
												}
											},
											"altText": "Motorcycle Amber Bullet Turn Signal"
										},
										"body": {
											"textList": [{
												"value": "Motorcycle Amber Bullet Turn Signal",
												"decoratorSet": []
											}]
										}
									}
								}
							},
							{
								"contentModuleType": "STANDARD_SINGLE_SIDE_IMAGE",
								"standardSingleSideImage": {
									"imagePositionType": "LEFT",
									"block": {
										"image": {
											"uploadDestinationId": "aplus-media/sc/f99e37a0-663c-43f6-b069-47944f233c30.jpg",
											"imageCropSpecification": {
												"size": {
													"width": {
														"value": 1600,
														"units": "pixels"
													},
													"height": {
														"value": 1600,
														"units": "pixels"
													}
												},
												"offset": {
													"x": {
														"value": 0,
														"units": "pixels"
													},
													"y": {
														"value": 0,
														"units": "pixels"
													}
												}
											},
											"altText": "Motorcycle Amber Bullet Turn Signal"
										},
										"headline": {
											"value": "Features:",
											"decoratorSet": []
										},
										"body": {
											"textList": [{
												"value": "These amber turn signals are used to clearly indicate the rider's intention to turn, improving riding safety and allowing other traffic participants to notice in time. Front and rear turn indicators for motorcycles provide full signaling functionality",
												"decoratorSet": []
											}]
										}
									}
								}
							},
							{
								"contentModuleType": "STANDARD_TECH_SPECS",
								"standardTechSpecs": {
									"specificationList": [{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Fury 2010-2016",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Interstate 1300 2010-2015",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Nighthawk 250 1991-2008",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Nighthawk 750 1991-2004 1982-1983",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Rebel 250 1985-1987 1996-2009 2012-2015",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Rebel 450 1986-1987",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Sabre 1300 2010-2015",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow 1100 1985-1990 1992-1998",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow 500 1983-1986",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow 700 1983-1987",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow 800 1988",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow ACE 1100 1995-2001",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow ACE 750 1997-2003",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow Aero 1100 1998-2002",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow Aero 750 2004-2016",
												"decoratorSet": []
											}
										},
										{
											"label": {
												"value": "Fitment:",
												"decoratorSet": []
											},
											"description": {
												"value": "Replacement for Honda Shadow Phantom 750 2010-2016 RS 750 2010-2013 Sabre 1100 2000-2008",
												"decoratorSet": []
											}
										}
									],
									"tableCount": 1
								}
							},
							{
								"contentModuleType": "STANDARD_THREE_IMAGE_TEXT",
								"standardThreeImageText": {
									"block1": {
										"image": {
											"uploadDestinationId": "aplus-media/sc/6370e53d-d35f-4f63-8abb-7e300309d9e6.jpg",
											"imageCropSpecification": {
												"size": {
													"width": {
														"value": 300,
														"units": "pixels"
													},
													"height": {
														"value": 300,
														"units": "pixels"
													}
												},
												"offset": {
													"x": {
														"value": 0,
														"units": "pixels"
													},
													"y": {
														"value": 0,
														"units": "pixels"
													}
												}
											},
											"altText": "Motorcycle Amber Bullet Turn Signal"
										}
									},
									"block2": {
										"image": {
											"uploadDestinationId": "aplus-media/sc/8144d482-88bf-4459-a5aa-82120a0f33b2.jpg",
											"imageCropSpecification": {
												"size": {
													"width": {
														"value": 300,
														"units": "pixels"
													},
													"height": {
														"value": 300,
														"units": "pixels"
													}
												},
												"offset": {
													"x": {
														"value": 0,
														"units": "pixels"
													},
													"y": {
														"value": 0,
														"units": "pixels"
													}
												}
											},
											"altText": "Motorcycle Amber Bullet Turn Signal"
										}
									},
									"block3": {
										"image": {
											"uploadDestinationId": "aplus-media/sc/67516ad3-0e63-4392-94c3-4a990b669a42.jpg",
											"imageCropSpecification": {
												"size": {
													"width": {
														"value": 300,
														"units": "pixels"
													},
													"height": {
														"value": 300,
														"units": "pixels"
													}
												},
												"offset": {
													"x": {
														"value": 0,
														"units": "pixels"
													},
													"y": {
														"value": 0,
														"units": "pixels"
													}
												}
											},
											"altText": "Motorcycle Amber Bullet Turn Signal"
										}
									}
								}
							},
							{
								"contentModuleType": "STANDARD_TEXT",
								"standardText": {
									"headline": {
										"value": "Note:",
										"decoratorSet": []
									},
									"body": {
										"textList": [{
												"value": "Power Connection Note: When connecting the power supply, please ensure that the motorcycle is powered off to prevent the risk of short circuit or electric shock Regular Inspection: Regularly check the working condition of the turn signal lamps to ensure that the brightness of the bulb is normal Avoid Excessive Vibration: Try to avoid extreme vibration or bumpy environments to prolong the life of your turn signals",
												"decoratorSet": [{
														"type": "LIST_UNORDERED",
														"offset": 0,
														"length": 416,
														"depth": 0
													},
													{
														"type": "LIST_ITEM",
														"offset": 0,
														"length": 161,
														"depth": 0
													},
													{
														"type": "LIST_ITEM",
														"offset": 161,
														"length": 135,
														"depth": 0
													},
													{
														"type": "LIST_ITEM",
														"offset": 296,
														"length": 120,
														"depth": 0
													}
												]
											},
											{
												"value": "",
												"decoratorSet": []
											},
											{
												"value": "Power Connection Note: When connecting the power supply, please ensure that the motorcycle is powered off to prevent the risk of short circuit or electric shock Regular Inspection: Regularly check the working condition of the turn signal lamps to ensure that the brightness of the bulb is normal Avoid Excessive Vibration: Try to avoid extreme vibration or bumpy environments to prolong the life of your turn signals",
												"decoratorSet": [{
														"type": "LIST_ORDERED",
														"offset": 0,
														"length": 416,
														"depth": 0
													},
													{
														"type": "LIST_ITEM",
														"offset": 0,
														"length": 161,
														"depth": 0
													},
													{
														"type": "LIST_ITEM",
														"offset": 161,
														"length": 135,
														"depth": 0
													},
													{
														"type": "LIST_ITEM",
														"offset": 296,
														"length": 120,
														"depth": 0
													}
												]
											},
											{
												"value": "",
												"decoratorSet": []
											},
											{
												"value": "",
												"decoratorSet": []
											},
											{
												"value": "",
												"decoratorSet": []
											}
										]
									}
								}
							}
						]
					}
				}
			};


			//代码样例（未使用）已转换成amis格式
			let saveApi = ()=>{
				let settings = {
					"url": "https://axg123.com/api/amazon/index",
					"method": "POST",
					"timeout": 0,
					"headers": {
						"Content-Type": "application/json",
						"Cookie": "PHPSESSID=ad698ef4bdca58132e50eb4558013e17"
					},
					"data": JSON.stringify({
						"textList": {
						"product_id": "43024",
						"template_id": "15",
						"StandardTextModule_body_RICHTEXT": "dsfasdfa",
						"StandardTextModule_headline_value": "asdfasdf"
						}
					}),
				};

				$.ajax(settings).done(function (response) {
					console.log(response);
				});
			}

			(function() {
				let amisLib = amisRequire('amis');
				let amis = amisRequire('amis/embed');
				let React = amisRequire('react');
				window.amisLib = amisLib;
				console.log('amisLib', amisLib);

				// 自定义组件，props 中可以拿到配置中的所有参数，比如 props.label 是 'Name'
				function CustomComponent(props) {
					const [val, setVal] = React.useState(props.$schema.value);
          			const [len, setLen] = React.useState(props.$schema.maxlen);
          
					
					/*
					
					// 示例用法
					var htmlString = '<div>Hello, <strong>world</strong>!</div>';
					var plainText = stripHtmlTags(htmlString);
					console.log(plainText); // 输出: Hello, world!
					*/
					function stripHtmlTags(html) {
						// 使用正则表达式匹配并移除所有HTML标签
						let result = html.replace(/<[^>]+>/g, '');
						return result;
					}
					
					function parseSpan(html){
						console.log('parseSpan1', html, typeof html);
						let arr = [];
						const matches = html.matchAll(/<span(.*?)>(.*?)<\/span>/g);//matchAll
						for (let match of matches) {
							console.log(match); // 输出每一对匹配的 "span"标签
							
							let str = html.substr(0,match.index);
							
							let offset = stripHtmlTags(str).length;
							
							let txtLen = match[2].length; //$(match[0]).text().length; 
							arr.push({
								"type": 'STYLE_UNDERLINE',
								"offset": offset,
								"length": txtLen,
								"depth": 0
							})
							
						}
						
						return arr;
					}
					
					function parseStrong(html){
						console.log('parseStrong', html);
						let arr = [];
						const matches = html.matchAll(/<strong(.*?)>(.*?)<\/strong>/g);//matchAll
						for (let match of matches) {
							console.log('parseStrong',match); // 输出每一对匹配的 "strong"标签
							
							let str = html.substr(0,match.index);
							
							let offset = stripHtmlTags(str).length;
							
							let txtLen = match[2].length; //$(match[0]).text().length; 
							arr.push({
								"type": 'STYLE_BOLD',
								"offset": offset,
								"length": txtLen,
								"depth": 0
							})
							
						}
						
						return arr;
					}
					
					function parseItalic(html){
						console.log('parseItalic', html);
						let arr = [];
						const matches = html.matchAll(/<em(.*?)>(.*?)<\/em>/g);//matchAll
						for (let match of matches) {
							console.log('parseItalic',match); // 输出每一对匹配的 "em"标签
							
							let str = html.substr(0,match.index);
							
							let offset = stripHtmlTags(str).length;
							
							let txtLen = match[2].length; //$(match[0]).text().length; 
							arr.push({
								"type": 'STYLE_ITALIC',
								"offset": offset,
								"length": txtLen,
								"depth": 0
							})
						}
						return arr;
					}
					
					
					//解析样式  斜体：<em>是是是</em>，粗体：<strong>喔喔</strong>
					const parsSty = (html) => {
						console.log('html111', html);
						// let parser = new DOMParser();
						// let doc = parser.parseFromString(html, "text/html");
						// console.log('doc111', doc);
						
						let spanarr = parseSpan(html);
						let strongarr = parseStrong(html);
						let iarr = parseItalic(html);
						
						return [...spanarr,...strongarr,...iarr];
					}
					//解析P标签
					const parsP = (html) => {
						console.log('parsP', html);
						if(html === '&nbsp;'){
							return {
								value: ' ',
								decoratorSet: []
							}
						}
						let text = $(html).text().replace(/\\n/ig, '');
						if (text === '') {
							return {
								value: '',
								decoratorSet: []
							}
						} else {
							//找出加粗，下划线，和倾斜 span
							let arr = parsSty(html);
							return {
								value: text,
								decoratorSet: arr
							}
						}
					}
					//解析UL标签
					const parsUL = (html_) => {
						let html = '<ul>'+html_+'</ul>';
						console.log('parsUL', html);
						let text = $(html).text().replace(/\\n/ig, '');
						let arr = [];

						arr.push({
							"type": "LIST_UNORDERED",
							"offset": 0,
							"length": text.length,
							"depth": 0
						})
						let offset = 0;
						$(html).children().each(function(index, value) {
							let item = $(value);
							let itemTxt = item.text();
							console.log("parsUL->li->"+index,itemTxt)
							arr.push({
								"type": "LIST_ITEM",
								"offset": offset,
								"length": itemTxt.length,
								"depth": 0
							})
							offset += itemTxt.length;
						});
						
						//找出加粗，下划线，和倾斜 span
						let arr2 = parsSty(html);
						return {
							value: text,
							decoratorSet: [...arr, ...arr2]
						}
					}
					//解析OL标签
					const parsOL = (html_) => {
						let html = '<ol>'+html_+'</ol>';
						console.log('parsOL', html);
						let text = $(html).text().replace(/\\n/ig, '');
						let arr = [];

						arr.push({
							"type": "LIST_ORDERED",
							"offset": 0,
							"length": text.length,
							"depth": 0
						})
						let offset = 0;
						$(html).children().each(function(index, value) {
							let item = $(value);
							let itemTxt = item.text();
							arr.push({
								"type": "LIST_ITEM",
								"offset": offset,
								"length": itemTxt.length,
								"depth": 0
							})
							offset += itemTxt.length;
						});
						//找出加粗，下划线，和倾斜 span
						let arr2 = parsSty(html);
						return {
							value: text,
							decoratorSet: [...arr, ...arr2]
						}
					}
					const htmlToJson = (html) => {
					
						// console.log('html,',html)
						//使用jquery库解析
						let $ctx__ = $('<div>' + html + '</div>');
						let jsonVal_ = [];
						$ctx__.children().each(function(index, val) {
							// console.log("序列：" + index + ", 值：" + value);
							let tag = $(val)[0].tagName;
							let value = $(val).html();
							console.log("tag1：", tag);
							console.log("tag2：", value);
							if (tag === 'P') {
								jsonVal_.push(parsP(value));
							} else if (tag === 'UL') {
								jsonVal_.push(parsUL(value));
							} else if (tag === 'OL') {
								jsonVal_.push(parsOL(value));
							}
						});
						console.log('jsonVal_', jsonVal_);
						return jsonVal_;
					}
					const jsonToHtml = (json) => {
						let jsonVal = [];
						let html = [];
						// //搜索文本
						// // debugger;
						// if (json && json.contentRecord) {
						// 	let cr = json.contentRecord;
						// 	if (cr && cr.contentDocument) {
						// 		let cd = cr.contentDocument;;
						// 		if (cd && cd.contentModuleList) {
						// 			let cml = cd.contentModuleList;
						// 			if (cml && cml.length > 0) {
						// 				for (let i = 0; i < cml.length; i++) {
						// 					let el = cml[i];
						// 					if (el.standardText && el.standardText.body && el.standardText.body
						// 						.textList) {
						// 						jsonVal = el.standardText.body.textList;
						// 						break;
						// 					}
						// 				}
						// 			}
						// 		}
						// 	}
						// }
						jsonVal = findNode(json,false);
						console.log('jsonVal', jsonVal);
						if (jsonVal.length > 0) {
							for (let i = 0; i < jsonVal.length; i++) {
								let el = jsonVal[i];
								if (el.value.length === 0 && el.decoratorSet.length === 0) {
									html.push('<p></p>');
								} else if (el.value.length > 0 && el.decoratorSet.length === 0) {
									
									html.push('<p>' + el.value + '</p>');
								} else if (el.value.length > 0 && el.decoratorSet.length > 0) {
									//点：ul->li  数字：ol->li
									let li_list = [];
									let wraper = el.decoratorSet[0].type === 'LIST_UNORDERED' ? 'ul' : 'ol'; //ul or ol
									let html__ = [];
								
									for (let k = 0; k < el.decoratorSet.length; k++) {
										let ds = el.decoratorSet[k];
										if (ds.type === 'LIST_ITEM') {
											li_list.push(`<li>${el.value.substr(ds.offset,ds.length)}</li>`);
										}
										
										// else if(ds.type === 'STYLE_UNDERLINE'){//处理下划线
											
										// }else if(ds.type === 'STYLE_BOLD'){//处理加粗
											
										// }else if(ds.type === 'STYLE_ITALIC'){//处理倾斜
											
										// }
										
									}
									
									//处理样式,先取出样式影响的字符串，然后在对应的位置插入带标签的字符串
									let decoratorSets = el.decoratorSet.filter(p => p.type === 'STYLE_UNDERLINE' ||
									p.type==='STYLE_BOLD' ||
									p.type==='STYLE_ITALIC');
									
									decoratorSets.sort((a, b) => b.offset - a.offset);
									for (let k = 0; k < decoratorSets.length; k++) {
										let ds = decoratorSets[k];
										ds.value = el.value.substr(ds.offset,ds.length);
									}
									for (let k = 0; k < decoratorSets.length; k++) {
										let ds = decoratorSets[k];
										let tpl = '';
										if(ds.type === 'STYLE_UNDERLINE'){//处理下划线
											tpl = `<span style="text-decoration: underline;">${ds.value}</span>`;
										}else if(ds.type === 'STYLE_BOLD'){//处理加粗
											tpl = `<strong>${ds.value}</strong>`
										}else if(ds.type === 'STYLE_ITALIC'){//处理倾斜
											tpl = `<em>${ds.value}</em>`
										}
										el.value = el.value.substring(0,ds.offset) + tpl + el.value.substring(ds.offset + ds.length,el.value.length);
									}
									html__ = `<${wraper}>${li_list.join('')}</${wraper}>`
									html.push(html__)
								}
							}
						}
						return html.join('');
					}

					console.log("props", props)
					let dir = props.formMode; //"horizontal"
					let value = props.$schema.value;
					let defaultHtml = '';
					if (value) {
						defaultHtml = jsonToHtml(value);
						// console.log('defaultHtml', defaultHtml);
					}
					let sc = {
						"type": "input-rich-text",
						"name": props.name + '_',
						"value": defaultHtml,
						"onEvent": {
							"change": {
								"actions": [{
									"actionType": "custom",
									// "script": "this.htmlToJson(event.data);event.stopPropagation();"
									"script": (context, doAction, event) => {
										let json_ = htmlToJson(event.data[props.name + '_']);
										let jsonVal_ = findNode(val,json_);
										setVal(jsonVal_);
										console.log('props.$schema.real',props.$schema.real);
										// console.log('json_', json_);
										// 第二个参数是要修改的表单项名称
										// onChange('new name', 'username');
										// context.props.onChange(event.data[props.name + '_'], props.name+'_');									// console.log('doAction',doAction);
										// context.props.onChange('aaaaaaaaaaa', props.name);
										// window.abc = context;
										// window.abc2 = doAction;
										// window.abc3 = event;
								
										event.context.scoped.parent.component.props.data[props.$schema.real] = json_;
										event.context.scoped.parent.component.forceUpdate();

                    // if()

                    // let html = event.data[props.name+'_'];

                    // let txt = stripHtmlTags(html);

                    // if(txt.length>len){

                    // }

										// window.abc2 = doAction;
										// let arg = {args: {value:{aaaa:'9999999999999999999'}}}
										// doAction({actionType:'setValue',componentId: props.$schema.real,arg})
										// console.log('event',event);
										console.log('最新的值',event.data[props.name+'_']);
									}
								}]
							}
						}
						,
						"options": {
							// setup: function (editor) {
							// 	editor.on('keyup', function (e) {
							// 	console.log('aaaaaaaaa',e);
							// 	var content = editor.getContent();
							// 	var maxChars = len;  // 设置最大字符数
							// 	if (content.length > maxChars) {
							// 		editor.setContent(content.substring(0, maxChars));  // 截断超过最大字符数的部分
							// 	}
							// 	});
							// },
							"menubar": false,
              				// "maxlength":len,
							"height": 200,
							"plugins": [
								// "advlist",
								// "autolink",
								// "link",
								// "image",
								"lists",
								// "charmap",
								// "preview",
								// "anchor",
								// "pagebreak",
								// "searchreplace",
								// "wordcount",
								// "visualblocks",
								// "visualchars",
								// "code",
								// "fullscreen",
								// "insertdatetime",
								// "media",
								// "nonbreaking",
								// "table",
								// "emoticons",
								// "template",
                				"underline",
								// "help"
							],
							"toolbar": "bold italic underline | bullist numlist"
						}
					};
					// let dom = React.useRef(null);
					// React.useEffect(function () {
					//   // 从这里开始写自定义代码，dom.current 就是新创建的 dom 节点
					//   // 可以基于这个 dom 节点对接任意 JavaScript 框架，比如 jQuery/Vue 等
					//   dom.current.innerHTML = 'custom';
					//   // 而 props 中能拿到这个
					// });
					// return React.createElement('div', {
					//   ref: dom
					// });

					// return amisLib.render(sc);
					// return <div data-role="form-item" data-amis-name="email" class="cxd-Form-item cxd-Form-item--horizontal"><label
					// 		class="cxd-Form-label cxd-Form-itemColumn--normal"><span><span
					// 				class="cxd-TplField"><span>Email</span></span></span></label>
					// 	<div class="cxd-Form-value">
					// 		<div class="cxd-Form-control cxd-TextControl">
					// 			<div class="cxd-TextControl-input"><input type="email" name="email" placeholder="" autocomplete="off"
					// 					size="10" class="" value=""></div>
					// 		</div>
					// 	</div>
					// </div>


					const createEditor = () => {
						return amisLib.render(sc);
					}
					const createFormLabel = () => {
						return React.createElement('label', {
								className: 'cxd-Form-label cxd-Form-itemColumn--normal'
							},
							null,
							React.createElement('span', {
								className: 'cxd-TplField'
							}, props.label)
						)
					}
					const createFormValue = () => {
						return React.createElement('div', {
								className: 'cxd-Form-value'
							},
							null,
							React.createElement('div', {
								className: 'cxd-Form-control cxd-RichTextControl'
							}, null, createEditor())
						)
					}
					const createFormItem = () => {
						return React.createElement('div', {
								className: 'cxd-Form-item cxd-Form-item--' + dir,
								dataRole: 'form-item',
								dataAmisName: props.name,
							},
							null,
							[createFormLabel(), createFormValue()]
						);
					}

					return createFormItem();
				}
				//注册自定义组件，请参考后续对工作原理的介绍
				amisLib.Renderer({
					test: /(^|\/)richjson/
				})(CustomComponent);

				// 通过替换下面这个配置来生成不同页面
				let amisJSON = {
					type: 'page',
					title: '表单页面',
					body: {
						type: 'form',
						debug: true,
						mode: 'horizontal',
						api: {
							method: 'post',
							url: 'https://axg123.com/api/amazon/index',
							dataType: "form",
							headers: {
								"Content-Type": "application/json",
								// "Cookie": "PHPSESSID=ad698ef4bdca58132e50eb4558013e17"
							},
							requestAdaptor: function (api, context) {
								console.log(context); // 打印上下文数据

								// return {
								// 	...api,
								// 	data: {
								// 	...api.data, // 获取暴露的 api 中的 data 变量
								// 	foo: 'bar' // 新添加数据
								// 	}
								// };

								return {
									...api,
									data:{
										textList: JSON.stringify(findNode(testJson))
									}
									
								}
							}
						},
						body: [{
								label: 'Name',
								type: 'input-text',
								name: 'name'
							},
							{
								label: 'Email',
								type: 'input-email',
								name: 'email'
							},
							{
								label: '自定义富文本',
								type: 'richjson',
								name: 'richjson1',
								real: 'abcd',
                maxlen: 50,
								value: testJson
							},
						]
					}
				};
				let amisScoped = amis.embed('#root', amisJSON);
			})();
		</script>
	</body>
</html>